package tests
{
	import com.as3undohistory.manage.IPropertyValueStack;
	import com.as3undohistory.manage.PropertyValueStack;
	import com.as3undohistory.register.AccessorRegistration;
	import com.as3undohistory.register.IAccessorRegistration;
	
	import flash.system.System;
	
	import flexunit.framework.TestCase;
	
	import tests.testclasses.UndoAbleTestClass;

	public class PropertyValueStackTest extends TestCase
	{
		public function PropertyValueStackTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public function testPush():void
		{
			var u:UndoAbleTestClass = new UndoAbleTestClass();
			var accessorReg:IAccessorRegistration = new AccessorRegistration("testStringPropertyChanged","testStringProperty");
			var propStack:IPropertyValueStack = new PropertyValueStack(u,accessorReg,"test");
			propStack.push("test2");
			assertEquals(1,propStack.count);
		}
		
		public function testPop():void
		{
			var u:UndoAbleTestClass = new UndoAbleTestClass();
			var accessorReg:IAccessorRegistration = new AccessorRegistration("testStringPropertyChanged","testStringProperty");
			var propStack:IPropertyValueStack = new PropertyValueStack(u,accessorReg,"test");
			propStack.push("test2");
			var str:String = propStack.pop() as String;
			assertEquals("test",str);
			assertEquals(0,propStack.count);
		}

		/*public function testWeakReference():void
		{
			var u:UndoAbleTestClass = new UndoAbleTestClass();
			var accessorReg:IAccessorRegistration = new AccessorRegistration("testStringPropertyChanged","testStringProperty");
			var propStack:IPropertyValueStack = new PropertyValueStack(u,accessorReg,"test");
			u = null;
			System.gc();
			assertNull(propStack.instance);
		}*/

	}
}